<template>
  <div class="demo">
    <h3 class="qwe">学生姓名：{{name}}</h3>
    <h3>学生年龄：{{age}}</h3>
    <button @click="sendDataToSchool">点我把数据发送给school组件</button>
  </div>
</template>

<script>
export default {
  name: 'student',
  data () {
    return {
      name: 'huihui',
      age: 18
    }
  },
  methods: {
    sendDataToSchool () {
      this.$bus.$emit('huihui', this.age)
    }
  },
  // 在这个组件销毁之前，把这个'huihui'事件解绑一下，别占着不用啊
  beforeDestroy () {
    this.$bus.$off('huihui')
  },
}
</script>

<style lang="less" scoped>
.demo {
  background-color: pink;
  .qwe {
    font-size: 40px;
  }
}
</style>